﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddTarifa.aspx.cs" Inherits="NewTierra.Pages.AddTarifa" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" tagprefix="ajaxToolkit"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

    <link href="../../Styles/EstiloGeral.css" rel="stylesheet" type="text/css" />

    <title></title>
    <style type="text/css">
        h1, h2, h3, h4, h5, h6
        {
            font-size: 1.5em;
            color: #666666;
            font-variant: small-caps;
            text-transform: none;
            font-weight: 200;
            margin-bottom: 0px;
        }
        #FormTarifa
        {
            height: 707px;
            width: 849px;
            padding: 10px;
        }
        #FormTarifa .Cabecalho
        {
            width: 263px;
            float: left;
        }
        #FormTarifa .GridPeriodos
        {
            width: 536px;
            float: left;
            height: 96px;
        }
        #FormTarifa .FormCadastroMeal
        {
            float: left;
            height: 298px;
            width: 360px;
            margin-left: 15px;
        }
        #FormTarifa .FormCadastroTarifas
        {
            float: left;
            width: 436px;
            height: 290px;
        }
        
        #FormTarifa .GridMeal
        {
            height: 225px;
            float: left;
            width: 360px;
            margin-left: 15px;
        }
        
        #FormTarifa .GridTarifas
        {
            height: 226px;
            float: left;
            width: 435px;
        }
        
        #body   
        {
         background-color:White;
         font-size: .80em;
         font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
         margin: 0px;
         padding: 0px;
         width: 860px;
         height: 755px;
        }

        .invisible { display: none; }
        
        .scrollGridTarifas  
        {
            width: 414px; 
            height: 199px; 
            overflow: auto; 
        }
        
        .scrollGridPeriodos
        {
            width: 359px; 
            height: 91px; 
            overflow: auto; 
        }
        
        #form1
        {
            height: 753px;
            width: 854px;
        }
        .taxas
        {
            width: 425px;
        }
        .taxas .comissao
        {
            width: 250px;
            float: left;
            height: 38px;
        }
        .taxas .porcentagens
        {
            width: 170px;
            float: left;
        }
        </style>
</head>
<body id="body">

    <script type="text/javascript">

        function CallServerCategoria() {
            document.getElementById('<%= btnFiltroNomeCategoria.ClientID %>').click();
        }

        function ShowIcon() {
            var e = document.getElementById("processing");
            e.style.visibility = (e.style.visibility == 'visible') ? 'hidden' : 'visible';
        }

    </script>

     <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager1" runat="server"/>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

    <div id="FormTarifa">

        <asp:Timer ID="TimerCriticaSupplier" runat="server" Interval="10000" OnTick="CriticaSupplierTarifa">
        </asp:Timer>

        <%--<asp:Button  id="btnCriticaSupplier" runat="server" Text="" style="display:none" OnClick="CriticaSupplierTarifa" />--%>

             <h1><asp:Label ID="lblSupplierTarifaTXT" runat="server" Text="Supplier:" />
                 <asp:Label ID="lblSupplierTarifa" runat="server" Font-Size="Small" Text="" /></h1> 
        <hr />

      <div class="Cabecalho">

              <asp:Label ID="lblMercadoTXT" runat="server" Text="Mercado:"></asp:Label>
        &nbsp;<asp:Label ID="lblMercado" runat="server" Font-Size="Small" Text=""></asp:Label><br />

              <asp:Label ID="lblBaseTarifariaTXT" runat="server" Text="Base Tarifária:"></asp:Label>
        &nbsp;<asp:Label ID="lblBaseTarifaria" runat="server" Font-Size="Small" Text=""></asp:Label><br />

               <asp:Label ID="lblMoedaTXT" runat="server" Text="Moeda:"></asp:Label>
        &nbsp;<asp:Label ID="lblMoeda" runat="server" Font-Size="Small" Text=""></asp:Label><br />
                
             <asp:Button ID="btnFecharTarifas" CssClass="btnsGeral" runat="server" Text="Fechar" OnClientClick="window.close();"/>

     </div>

     <div class="GridPeriodos">
        <div class="scrollGridPeriodos">
                 <asp:GridView ID="GridTarifasPeriodo" 
                 runat="server"
                 AutoGenerateColumns="False" 
                 GridLines="None" 
                 CssClass="mGrid" 
                 EmptyDataText="Não existe Periodos para esse Supplier."
                 Height="16px"
                 Width="94px"
                 PageSize="3" AllowSorting="True" OnSorting="SortCommandPeriodo" 
                 onselectedindexchanged="GridTarifasPeriodo_SelectedIndexChanged">

           <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
                      <SelectedRowStyle CssClass="SelectedRowStyle" />
           <Columns>

           <asp:BoundField DataField="S_merc_periodo_id" HeaderText="ID" ReadOnly="True" 
                      SortExpression="S_merc_periodo_id" InsertVisible="False">

               <FooterStyle CssClass="invisible" />
               <HeaderStyle CssClass="invisible" />
               <ItemStyle CssClass="invisible" />
               </asp:BoundField>

                 <asp:BoundField DataField="S_merc_periodo_from" HeaderText="From" 
                     SortExpression="S_merc_periodo_from" DataFormatString="{0:dd/MM/yy}">
                     <HeaderStyle ForeColor="#666" />
                      <ItemStyle Wrap="False" />
               </asp:BoundField>

                      <asp:BoundField DataField="S_merc_periodo_to" HeaderText="To" 
                     SortExpression="S_merc_periodo_to" DataFormatString="{0:dd/MM/yy}">
                                                <HeaderStyle ForeColor="#666" />
                          <ItemStyle Wrap="False" />
               </asp:BoundField>

                      <asp:BoundField DataField="S_mercado_estacao_nome" HeaderText="Estação" 
                     SortExpression="S_mercado_estacao_nome">
                                           <HeaderStyle ForeColor="#666" />
                      <ItemStyle Wrap="False" />
               </asp:BoundField>
                     
                      <asp:BoundField DataField="S_mercado_per_fds_from" HeaderText="Fds From" 
                     SortExpression="S_mercado_per_fds_from" 
                   DataFormatString="{0:dd/MM/yy}">

                          <HeaderStyle Wrap="False" />
                                                <HeaderStyle ForeColor="#666" />
                          <ItemStyle Wrap="False" />
               </asp:BoundField>

                      <asp:BoundField DataField="S_mercado_per_fds_to" HeaderText="Fds To" 
                     SortExpression="S_mercado_per_fds_to" DataFormatString="{0:dd/MM/yy}">

                          <HeaderStyle Wrap="False" />
                                                <HeaderStyle ForeColor="#666" />
                          <ItemStyle Wrap="False" />
               </asp:BoundField>

               <asp:CommandField HeaderText="Select" ShowSelectButton="True" />

        </Columns>

        <PagerStyle CssClass="pgr"></PagerStyle>

        </asp:GridView>
        </div>

     </div>
    
     <div class="FormCadastroTarifas">
    
            <fieldset id="FieldSetTarifas" runat="server">
            <legend>Adicionar Tarifas</legend>
            

                    <asp:Label ID="lblTipoTarifa" runat="server" Text="Tipo Tarifa:"></asp:Label>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="lblTipoRoom" runat="server" Text="Tipo Room:"></asp:Label><br />
                    <asp:DropDownList ID="DropTipoTarifa" runat="server"></asp:DropDownList>
                &nbsp;&nbsp;&nbsp;<asp:DropDownList ID="DropTipoRoom" runat="server" 
                    AutoPostBack="True" onselectedindexchanged="DropTipoRoom_SelectedIndexChanged"></asp:DropDownList>
                    
                    <br />
          
                    <asp:Label ID="lblCategoria" runat="server" Text="Categoria:"></asp:Label>
                    &nbsp;<asp:LinkButton ID="lnkAddCategoria" runat="server" Text="Add" OnClick="AddCategoria" /><br />
                    <asp:DropDownList ID="DropCategoria" runat="server">
                    </asp:DropDownList>
                    <asp:TextBox ID="txtAddCategoria" runat="server" Visible="false"/>
                    <asp:Button ID="btnAddCategoria" CssClass="btnsGeral" runat="server" Visible="false" Text="Salvar" OnClick="SalvarCategoria" />
                    <ajaxToolkit:AutoCompleteExtender 
                    ServiceMethod="SearchCategorias"
                    MinimumPrefixLength="1" 
                    CompletionInterval="100" 
                    EnableCaching="False" 
                    TargetControlID="txtAddCategoria" 
                    onclientpopulating="ShowIcon"
                    onclientpopulated="ShowIcon"
                    ID="AutoCompleteCategorias" 
                    runat="server"
                    onclientitemselected="CallServerCategoria" 
                    DelimiterCharacters="" 
                    Enabled="True" 
                    ServicePath="">
                    </ajaxToolkit:AutoCompleteExtender>
                     
                     <img id="processing" alt="load" style="visibility:hidden" 
                    src="../../images/ajax-loader.gif" />
                    <asp:Button ID="btnFiltroNomeCategoria" runat="server" Text="" OnClick="SelectCategoria" style="display:none;" />
                    <br />

                    <asp:RadioButtonList ID="RdoTarifa" runat="server" AutoPostBack="True" 
                    RepeatDirection="Horizontal" Width="250px" Height="16px" 
                    onselectedindexchanged="RdoTarifa_SelectedIndexChanged">
                    <asp:ListItem Value="0">Por Pessoa</asp:ListItem>
                    <asp:ListItem Value="1" Selected="True">Por Apartamento</asp:ListItem>
                    </asp:RadioButtonList>

                    <asp:Label ID="lblStatusTarifaTXT" runat="server" Text="Status/Tarifa:"></asp:Label><br />
                    <asp:TextBox ID="txtStatusTarifa" runat="server" Width="50px" 
                        AutoPostBack="True" ontextchanged="txtStatusTarifa_TextChanged"></asp:TextBox>
                    <asp:RequiredFieldValidator
                        ID="requiredTarifa" 
                        runat="server" 
                        ErrorMessage="*" 
                        ToolTip="Campo requerido." 
                        ValidationGroup="SalvarTarifa"
                        ControlToValidate="txtStatusTarifa" />

                    <asp:Label ID="lblErroStatusValorTarifa" runat="server" Text=""></asp:Label>

                    &nbsp;<asp:Label ID="lblTotalTarifaTXT" runat="server" Text="Total:"></asp:Label>
                    <asp:TextBox ID="txtStatusTarifaTotal" runat="server" Width="50px" 
                        Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="chkValor" runat="server" Text="Valor?" 
                        AutoPostBack="True" oncheckedchanged="chkValor_CheckedChanged" />
                    <asp:DropDownList ID="DropStatusTarif" runat="server" Visible="False">
                    </asp:DropDownList>
                    <asp:LinkButton ID="lnkVoltarStatus" runat="server" 
                        onclick="lnkVoltarStatus_Click" Visible="False">Voltar</asp:LinkButton>
                        <br />

                    <asp:Panel ID="PanelPorcentagemTarifas" runat="server">

                       <div class="taxas">
                           <div class="porcentagens">
                        <asp:Label ID="lblPorcetagemTarifaTXT" runat="server" Text="Taxas:"></asp:Label><br />
                        <asp:TextBox ID="txtPorcentagemTaxa" runat="server" Width="50px" 
                            AutoPostBack="True" ontextchanged="txtPorcentagemTaxa_TextChanged">0</asp:TextBox>
                        %&nbsp;&nbsp;&nbsp;
                        <asp:TextBox ID="txtPorcentagemImposto" runat="server" Width="50px" 
                            AutoPostBack="True" ontextchanged="txtPorcentagemTaxa_TextChanged">0</asp:TextBox>
                        % 
                           </div>
                           <div class="comissao">
                             <asp:Label ID="lblComissaoTXT" runat="server" Text="Comissão:"></asp:Label><br />
                             <asp:TextBox ID="txtComissao" runat="server" Width="50px" AutoPostBack="True" ontextchanged="txtComissao_TextChanged" Text="0" />
                               %</div>
                        <br />
                       </div>
                    </asp:Panel>
                    
                    <br /><br />

                    <asp:Button ID="btnSalvarTarifa" CssClass="btnsGeral" runat="server" Text="Salvar" 
                        ValidationGroup="SalvarTarifa" onclick="SalvarTarifa" />

                         <asp:Button ID="btnAtualizarTarifa" CssClass="btnsGeral" runat="server" Text="Atualizar" 
                        ValidationGroup="Salvar" onclick="AtualizarTarifa" />

                         <asp:Button ID="btnExcluirTarifa" CssClass="btnsGeral" runat="server" Text="Excluir" 
                        ValidationGroup="Salvar" onclick="ExcluirTarifa" />
                        <br />
                    &nbsp;<asp:Label ID="lblMsgAddTarifa" runat="server" Font-Bold="True" 
                         ForeColor="#CC0000" Font-Size="Small"></asp:Label>

                                     </fieldset>
    
    </div>

    <div class="FormCadastroMeal">
    

            <fieldset>
             <legend>Adicionar Meal</legend>

                    <asp:Label ID="lblStatusMealTXT" runat="server" Text="Status/Tarifa:"></asp:Label><br />

                    <asp:TextBox ID="txtStatusMeal" runat="server"
                    AutoPostBack="True" ontextchanged="txtStatusMeal_TextChanged" Width="50px"></asp:TextBox>
                       <asp:RequiredFieldValidator
                        ID="requiredStatusMeal" 
                        runat="server" 
                        ErrorMessage="*" 
                        ToolTip="Campo requerido." 
                        ValidationGroup="SalvarMeal"
                        ControlToValidate="txtStatusMeal" />

                    <asp:Label ID="lblErroStatusValorMeal" runat="server" Text="" />
                    &nbsp;<asp:Label ID="lblTotalMealTXT" runat="server" Text="Total:"></asp:Label>
                    <asp:TextBox ID="txtStatusMealTotal" runat="server" Width="50px" 
                        Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="chkValorMeal" runat="server" Text="Valor?" 
                        AutoPostBack="True" oncheckedchanged="chkValorMeal_CheckedChanged" />
                    <asp:DropDownList ID="DropStatusMeal" runat="server" Visible="False">
                    </asp:DropDownList>
                    <asp:LinkButton ID="lnkVoltarStatusMeal" runat="server" onclick="lnkVoltarStatusMeal_Click" Visible="False">Voltar</asp:LinkButton>
                    <br />

                    <asp:Panel ID="PanelPorcentagemMeal" runat="server">
                        <asp:Label ID="lblPorcetagemMealTXT" runat="server" Text="Taxas:"></asp:Label><br />
                        <asp:TextBox ID="txtPorcentagemTaxaMeal" runat="server" Width="50px" 
                            AutoPostBack="True" ontextchanged="txtPorcentagemTaxaMeal_TextChanged">0</asp:TextBox>
                        %&nbsp;&nbsp;&nbsp;
                        <asp:TextBox ID="txtPorcentagemImpostoMeal" runat="server" Width="50px" 
                            AutoPostBack="True" ontextchanged="txtPorcentagemImpostoMeal_TextChanged">0</asp:TextBox>
                        %
                        <br />
                    </asp:Panel>

                    <asp:Label ID="lblTipoMealTXT" runat="server" Text="Meal:"></asp:Label><br />
                    <asp:DropDownList ID="DropMeal" runat="server">
                    </asp:DropDownList>
                    <br /><br />

                    <asp:Button ID="btnSalvarMeal" CssClass="btnsGeral" runat="server" Text="Salvar" 
                        ValidationGroup="SalvarMeal" onclick="SalvarMeal" />

                        <asp:Button ID="btnAtualizarMeal" CssClass="btnsGeral" runat="server" Text="Atualizar" 
                        ValidationGroup="Salvar" onclick="AtualizarMeal" />

                        <asp:Button ID="btnExcluirMeal" CssClass="btnsGeral" runat="server" Text="Excluir" 
                        ValidationGroup="Salvar" onclick="ExcluirMeal" />

                        <br />
                    &nbsp;<asp:Label ID="lblMsgAddMeal" runat="server" Font-Bold="True" 
                         ForeColor="#CC0000" Font-Size="Small"></asp:Label></td>

                 </fieldset>
    </div>

    <div class="GridTarifas">
    
    <fieldset>
    <legend>Tarifas Cadastradas</legend>
     <div class="scrollGridTarifas">

      <asp:GridView ID="GridTarifas" runat="server" AllowPaging="True"
         AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" EmptyDataText="Não existe Tarifa cadastrada para esse periodo."
            Height="16px" OnSorting="SortCommandTarifa" AllowSorting="True"
                Width="228px" PageSize="50" 
            onselectedindexchanged="GridTarifas_SelectedIndexChanged">
           <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
           <SelectedRowStyle CssClass="SelectedRowStyle" />
            <Columns>
                 <asp:BoundField DataField="S_merc_tarif_id" HeaderText="ID" SortExpression="S_merc_tarif_id">
                 <HeaderStyle CssClass="invisible" />
                 <FooterStyle CssClass="invisible" />
                 <ItemStyle CssClass="invisible" />
                 </asp:BoundField>

                 <asp:BoundField DataField="S_mercado_tipo_tarifa_nome" HeaderText="Tarifa Nome"  SortExpression="S_mercado_tipo_tarifa_nome" >
                 <HeaderStyle Wrap="False" />
                 <ItemStyle Wrap="False" />
                     <HeaderStyle ForeColor="#666" />
                 </asp:BoundField>

                 <asp:BoundField DataField="Tarif_categoria_nome" HeaderText="Categoria" 
                     SortExpression="Tarif_categoria_nome" >
                 <HeaderStyle ForeColor="#666" />
                 <ItemStyle Wrap="False" />
                 </asp:BoundField>

                  <asp:BoundField DataField="Tipo_room_nome" HeaderText="Room" SortExpression="Tipo_room_nome">
                  <ItemStyle Wrap="False" />
                      <HeaderStyle ForeColor="#666" />
                 </asp:BoundField>
                 
                 <asp:BoundField DataField="S_merc_tarif_tarifa_total" HeaderText="Tarifa" SortExpression="S_merc_tarif_tarifa_total">
                 <HeaderStyle ForeColor="#666" />    
                 </asp:BoundField>
                 
                 <asp:BoundField DataField="S_mercado_tarifa_status_nome" HeaderText="Status" SortExpression="S_mercado_tarifa_status_nome" >
                 <HeaderStyle ForeColor="#666" />
                 <ItemStyle Wrap="False" />
                 </asp:BoundField>
                 
                 <asp:CommandField ShowSelectButton="True" SelectText="Editar" />
                 
            </Columns>
        
        <PagerStyle CssClass="pgr"></PagerStyle>

        </asp:GridView>

        </fieldset>
    
    </div>

    <div class="GridMeal">
    
    <fieldset>
        <legend>Meals Cadastrados</legend>
    
      <asp:GridView ID="GridMeal" runat="server" AllowPaging="True"
         AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" EmptyDataText="Não existe Meal cadastrado para esse periodo."
            Height="16px" OnPageIndexChanging="PaginarDadosMeal" Width="307px" 
            PageSize="5" onselectedindexchanged="GridMeal_SelectedIndexChanged">
           <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
           <SelectedRowStyle CssClass="SelectedRowStyle" />
           <Columns>
          
             <asp:BoundField DataField="S_merc_meal_id" HeaderText="ID" SortExpression="S_merc_meal_id">
                 <HeaderStyle CssClass="invisible" />
                 <FooterStyle CssClass="invisible" />
                 <ItemStyle CssClass="invisible" />
                 </asp:BoundField>

                <asp:BoundField DataField="S_meal_nome" HeaderText="Meal" 
                    SortExpression="S_meal_nome" />
                
                <asp:BoundField DataField="S_merc_meal_tarifa_total" HeaderText="Tarifa" SortExpression="S_merc_meal_tarifa_total" />
               
                <asp:BoundField DataField="S_mercado_tarifa_status_nome" HeaderText="Status" SortExpression="S_mercado_tarifa_status_nome" />
           
             <asp:CommandField ShowSelectButton="True" />

           </Columns>
        
        <PagerStyle CssClass="pgr"></PagerStyle>

        </asp:GridView>

        </fieldset>
    </div>

      </div>

     </ContentTemplate>
     </asp:UpdatePanel>
    
    </form>
</body>
</html>
